require('./PageEng.less');
import { Control, Route } from 'react-keeper';
import React,{Component} from 'react';
import Reflux from 'reflux';
import ReactMixin from 'react-mixin';
import EngInfo from '../../../components/eng/EngInfo';
import EngItem from '../../../components/eng/EngItem';
import Actions from './Actions'
import Store from './Store';
import 'weui';
import { Tab,TabBarItem,TabBar,Page,Article,
  Panel,
  PanelHeader,
  PanelBody,
  PanelFooter,
  MediaBox,
  MediaBoxHeader,
  MediaBoxBody,
  MediaBoxTitle,
  MediaBoxDescription,
  MediaBoxInfo,
  MediaBoxInfoMeta,
  Cells,
  Cell,
  CellHeader,
  CellBody,
  CellFooter,
  Flex,
  FlexItem,
  Grids
} from  'react-weui/build/packages'




class Eng extends Component {
    constructor(props) {
      super(props);
      this.state = {
        actshow: false
      }
      this.handleChange = this.handleChange.bind(this);
      this.myHome = this.myHome.bind(this);
      this.onEngFetch = this.onEngFetch.bind(this);
    }

    handleChange(key){
        //this.dispatch('setTabbarIndex',key);
        //Control.go(this.state.menu[key].path, ); // keeper的跳转
    }

    myHome() {
      Control.go('/home');
    }

    render() {
      const t = this;
        return (
          <div className="page eng">
            <EngInfo engls={t.state.eng.engls} />

{/*            <Panel className="head-panel">
              <PanelHeader>
                <div className="title-bg"/>
                参建工程
              </PanelHeader>
              <PanelBody>
                <Flex>
                  <FlexItem >
                    {
                      t.state.eng.engls.map((item, index) => {
                        return(
                          <EngItem eng={item} key={index}/>
                        )
                      })
                    }
                  </FlexItem>
                </Flex>
              </PanelBody>
            </Panel>*/}

          </div>
        );
    }


    componentWillMount() {
      Actions.engInit();
    }

    componentDidMount() {
    }

    onEngFetch(obj, callback) {
      Actions.engFetch(obj, callback);

    }

  shouldComponentUpdate(nextProps = {}, nextState = {}) {
    const thisProps = this.props || {},
      thisState = this.state.eng || {};

    if (Object.keys(thisProps).length !== Object.keys(nextProps).length ||
      Object.keys(thisState).length !== Object.keys(nextState).length) {
      return true;
    }

    for (const key in nextProps) {
      if (thisProps[key] !== nextProps[key] || !is(thisProps[key], nextProps[key])) {
        console.log(thisProps[key], nextProps[key]);
        return true;
      }
    }

    for (const key in nextState) {
      if (thisState[key] !== nextState[key] || !is(thisState[key], nextState[key])) {
        return true;
      }
    }

    return true;
  }

  shouldComponentUpdate(nextProps, nextState) {
    return true;
  }

}

ReactMixin.onClass(Eng, Reflux.connect(Store, 'eng'));

export default Eng ;
